package designMode.factoryPattern;

import lombok.extern.log4j.Log4j;
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.collections.CollectionUtils;
import org.apache.ibatis.jdbc.Null;
import retrofit2.http.HEAD;

import java.util.logging.Logger;

import static designMode.factoryPattern.VisitEnum.getVisit;

/**
 * 陆离
 * 2023/11/9 9:23:06
 */
public class LoggerFactory {
    public static ILog createLogger(String type) {
        if ("file".equals(type)) {
            System.out.println(111);
            System.out.println(111);
            System.out.println(111);
            System.out.println(222);
            return new FileLog();
        } else if ("database".equals(type)) {
            System.out.println(222);
            return new DatabaseLog();
        } else if ("console".equals(type)) {
            return new ConsoleLog();
        } else {
            throw new IllegalArgumentException("unsupported type: " + type);
        }
    }

    public static void main(String[] args) {
        ILog log = LoggerFactory.createLogger("database");
        log.writeLog();
        try {
            getVisit("con1sole").writeLog();
        }catch (NullPointerException e){
            System.out.println("空指针");
        }

    }
}
